Other Functions

The following functions are available globally.

  • Converts an annotation type into the string representation.

    Declaration

    Objective-C

    extern PSPDFAnnotationString _Nullable PSPDFStringFromAnnotationType(
        PSPDFAnnotationType annotationType)
  • Converts the annotation type string representation to an annotation type.

    Declaration

    Objective-C

    extern PSPDFAnnotationType
        PSPDFAnnotationTypeFromString(PSPDFAnnotationString _Nullable string)
  • Localizes the annotation type / variant string. If you have an annotation object, use the localizedType property instead of this function.

    Declaration

    Objective-C

    extern NSString *_Nonnull PSPDFLocalizeAnnotationType(
        PSPDFAnnotationString _Nonnull type,
        PSPDFAnnotationVariantString _Nullable variant)
  • Deprecated

    Deprecated in PSPDFKit 4.3 for macOS. This functionality should not be needed and will be removed in a future update. PSPDFFileAnnotationProvider already takes care of registering the appropriate overrides when reading an external annotation file.

    Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT void PSPDFAnnotationRegisterOverrideClasses(NSKeyedUnarchiver *unarchiver, PSPDFDocument *document) PSPDF_DEPRECATED(9.3, 4.3, "This functionality should not be needed and will be removed in a future update. `PSPDFFileAnnotationProvider` already takes care of registering the appropriate overrides when reading an external annotation file.")

    Swift

    func PSPDFAnnotationRegisterOverrideClasses(_ unarchiver: NSKeyedUnarchiver, _ document: PSPDFDocument)
  • Simple helper that combines a state + variant into a new identifier. Can be used to set custom types in the PSPDFStyleManager.

    Declaration

    Objective-C

    extern PSPDFAnnotationStateVariantID _Nonnull PSPDFAnnotationStateVariantIDMake(
        PSPDFAnnotationString _Nonnull,
        PSPDFAnnotationVariantString _Nullable variant)
  • Returns the original annotation state from a string that previously has been generated by PSPDFAnnotationStateVariantIDMake.

    Declaration

    Objective-C

    extern PSPDFAnnotationString _Nonnull PSPDFAnnotationStateFromStateVariantIdentifier(
        PSPDFAnnotationStateVariantID _Nonnull)
  • Returns the original annotation state variant from a string that previously has been generated by PSPDFAnnotationStateVariantIDMake.

    Declaration

    Objective-C

    extern PSPDFAnnotationVariantString _Nullable PSPDFAnnotationVariantFromStateVariantIdentifier(
        PSPDFAnnotationStateVariantID _Nonnull)
  • A helper to quickly determine if a coordinated data provider provides conflict resolution at a given moment.

    Declaration

    Objective-C

    extern BOOL PSPDFConflictResolutionAvailableForDataProvider(
        id<PSPDFCoordinatedFileDataProviding> _Nonnull dataProvider)

    Swift

    func ConflictResolutionAvailable(forDataProvider dataProvider: CoordinatedFileDataProviding) -> Bool

    Parameters

    dataProvider

    The data provider to check.

    Return Value

    true if conflict resolution APIs are implemented and conflict resolution is currently possible. false in all other cases.

  • Returns true, if all values are different from NAN and +inf/-inf.

    Declaration

    Objective-C

    extern BOOL PSPDFDrawingPointIsFinite(PSPDFDrawingPoint point)

    Swift

    var isFinite: Bool { get }
  • Yes when the location and intensity values match.

    Declaration

    Objective-C

    extern BOOL PSPDFDrawingPointIsEqualToPoint(PSPDFDrawingPoint point,
                                                PSPDFDrawingPoint otherPoint)

    Swift

    func isEqual(_ otherPoint: DrawingPoint) -> Bool
  • Converts the point into a string representation.

    Declaration

    Objective-C

    extern NSString *_Nonnull PSPDFDrawingPointToString(PSPDFDrawingPoint point)

    Swift

    var debugDescription: String { get }
  • The reverse operation to PSPDFDrawingPointToString. Returns PSPDFDrawingPointNull is parsing fails.

    Declaration

    Objective-C

    extern PSPDFDrawingPoint PSPDFDrawingPointFromString(NSString *_Nonnull string)

    Swift

    /*not inherited*/ init(string: String)
  • Creates a new PSPDFDrawingPoint.

    Declaration

    Objective-C

    extern PSPDFDrawingPoint PSPDFDrawingPointMake(CGPoint location,
                                                   CGFloat intensity)
  • Creates a new PSPDFDrawingPoint from a CGPoint, using PSPDFDefaultIntensity.

    Declaration

    Objective-C

    extern PSPDFDrawingPoint PSPDFDrawingPointFromCGPoint(CGPoint location)

    Swift

    /*not inherited*/ init(cgPoint location: CGPoint)
  • Deprecated

    Deprecated in PSPDFKit 5.0 for macOS. Use PSPDFDrawingPointIsFinite instead.

    Deprecated. Use PSPDFDrawingPointIsFinite instead.

    Declaration

    Objective-C

    extern BOOL PSPDFDrawingPointIsValid(PSPDFDrawingPoint point)

    Swift

    var isValid: Bool { get }
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CTTextAlignment PSPDFTextAlignmentToCTTextAlignment(NSTextAlignment nsTextAlignment)

    Swift

    func PSPDFTextAlignmentToCTTextAlignment(_ nsTextAlignment: NSTextAlignment) -> CTTextAlignment
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CGRect PSPDFEdgeInsetInsetRect(CGRect rect, UIEdgeInsets insets)

    Swift

    func PSPDFEdgeInsetInsetRect(_ rect: CGRect, _ insets: NSEdgeInsets) -> CGRect
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT NSString *NSStringFromPSPDFEdgeInset(UIEdgeInsets insets)

    Swift

    func NSStringFromPSPDFEdgeInset(_ insets: NSEdgeInsets) -> String!
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT UIEdgeInsets PSPDFEdgeInsetFromString(NSString *string)

    Swift

    func PSPDFEdgeInsetFromString(_ string: String!) -> NSEdgeInsets
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT NSString *PSPDF_NSStringFromCGPoint(CGPoint point)

    Swift

    func PSPDF_NSStringFromCGPoint(_ point: CGPoint) -> String!
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT NSString *PSPDF_NSStringFromCGSize(CGSize size)

    Swift

    func PSPDF_NSStringFromCGSize(_ size: CGSize) -> String!
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT NSString *PSPDF_NSStringFromCGRect(CGRect rect)

    Swift

    func PSPDF_NSStringFromCGRect(_ rect: CGRect) -> String!
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT NSString *PSPDF_NSStringFromCGAffineTransform(CGAffineTransform transform)

    Swift

    func PSPDF_NSStringFromCGAffineTransform(_ transform: CGAffineTransform) -> String!
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CGPoint PSPDF_CGPointFromString(NSString *string)

    Swift

    func PSPDF_CGPointFromString(_ string: String!) -> CGPoint
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CGSize PSPDF_CGSizeFromString(NSString *string)

    Swift

    func PSPDF_CGSizeFromString(_ string: String!) -> CGSize
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CGRect PSPDF_CGRectFromString(NSString *string)

    Swift

    func PSPDF_CGRectFromString(_ string: String!) -> CGRect
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CGAffineTransform PSPDF_CGAffineTransformFromString(NSString *string)

    Swift

    func PSPDF_CGAffineTransformFromString(_ string: String!) -> CGAffineTransform
  • Converts an array of glyphs to a string.

    Declaration

    Objective-C

    extern NSString *_Nonnull PSPDFStringFromGlyphs(
        NSArray<PSPDFGlyph *> *_Nullable glyphs)

    Swift

    func PSPDFStringFromGlyphs(_ glyphs: [Glyph]?) -> String
  • Returns the bounding box that includes all glyphs.

    Declaration

    Objective-C

    extern CGRect
    PSPDFBoundingBoxFromGlyphs(NSArray<PSPDFGlyph *> *_Nullable glyphs)

    Swift

    func PSPDFBoundingBoxFromGlyphs(_ glyphs: [Glyph]?) -> CGRect

    Return Value

    Rect encompassing all glyphs or CGRectZero if glyphs is empty.

  • Global helper to convert glyphs to rects.

    Declaration

    Objective-C

    extern NSArray<NSValue *> *_Nonnull PSPDFRectsFromGlyphs(
        NSArray<PSPDFGlyph *> *_Nullable glyphs, CGRect *_Nonnull boundingBox)

    Swift

    func PSPDFRectsFromGlyphs(_ glyphs: [Glyph]?, _ boundingBox: UnsafeMutablePointer<CGRect>) -> [NSValue]
  • Returns an NSRange representing the glyphs in glyphs, assuming they are in ascending order of their indexOnPage. If glyphs is not sorted, this method this method will return a wrong result. PSPDFInvalidGlyphRange is returned an empty array, or if the last glyph has an indexOnPage that is prior to the first one.

    Declaration

    Objective-C

    extern NSRange PSPDFRangeFromGlyphs(NSArray<PSPDFGlyph *> *_Nonnull glyphs)

    Swift

    func PSPDFRangeFromGlyphs(_ glyphs: [Glyph]) -> NSRange
  • Calculates the bounding box from lines.

    Declaration

    Objective-C

    extern CGRect PSPDFBoundingBoxFromLines(NSArray *_Nonnull lines,
                                            CGFloat lineWidth)

    Swift

    func BoundingBoxFromLines(_ lines: [Any], lineWidth: CGFloat) -> CGRect

    Parameters

    lines

    Either an NSArray<PSPDFPointArray *> or NSArray<NSArray<NSValue *> *>.

  • Will convert view lines to PDF lines (operates on every point)

    Declaration

    Objective-C

    extern NSArray<NSArray<NSValue *> *> *_Nonnull PSPDFConvertViewLinesToPDFLines(
        NSArray<NSArray<NSValue *> *> *_Nonnull lines,
        PSPDFPageInfo *_Nonnull pageInfo, CGRect viewBounds)

    Swift

    func ConvertViewLines(pdfLines lines: [[NSValue]], pageInfo: PSPDFPageInfo, viewBounds: CGRect) -> [[NSValue]]
  • Converts a single line of boxed PSPDFDrawingPoints.

    Declaration

    Objective-C

    extern NSArray<NSValue *> *_Nonnull PSPDFConvertViewLineToPDFLines(
        NSArray<NSValue *> *_Nonnull line, PSPDFPageInfo *_Nonnull pageInfo,
        CGRect viewBounds)

    Swift

    func ConvertViewLine(pdfLine line: [NSValue], pageInfo: PSPDFPageInfo, viewBounds: CGRect) -> [NSValue]
  • Will convert PDF lines to view lines (arrays of PSPDFDrawingPoints) (operates on every point)

    Declaration

    Objective-C

    extern NSArray<NSArray<NSValue *> *> *_Nonnull PSPDFConvertPDFLinesToViewLines(
        NSArray<NSArray<NSValue *> *> *_Nonnull lines,
        PSPDFPageInfo *_Nonnull pageInfo, CGRect viewBounds)

    Swift

    func ConvertPDFLines(viewLines lines: [[NSValue]], pageInfo: PSPDFPageInfo, viewBounds: CGRect) -> [[NSValue]]
  • Localizes strings. Will first look up the string in the PSPDFKit.bundle

    Declaration

    Objective-C

    extern NSString *_Nonnull PSPDFLocalize(NSString *_Nullable stringToken)

    Swift

    func localizedString(_ stringToken: String?) -> String
  • Localizes strings with a list of arguments to substitute into stringToken.

    Declaration

    Objective-C

    extern NSString *_Nonnull PSPDFLocalizeFormatted(NSString *_Nonnull stringToken,
                                                     ...)
  • Sets a custom dictionary that contains dictionaries with language locales. Will override localization found in the bundle, if a value is found. Falls back to “en” if localization key is not found in dictionary. Set on the main thread.

    Declaration

    Objective-C

    extern void PSPDFSetLocalizationDictionary(
        NSDictionary<NSString *, NSDictionary<NSString *, NSString *> *>
            *_Nullable localizationDict)

    Swift

    func setLocalizationDictionary(_ localizationDict: [String : [String : String]]?)
  • Register a custom block that handles translation. If this block is NULL or returns nil, localizationDict followed by the PSPDFKit.bundle will be used.

    Declaration

    Objective-C

    extern void PSPDFSetLocalizationBlock(
        NSString *_Nullable (^_Nonnull localizationBlock)(NSString *_Nullable))

    Swift

    func setLocalizationClosure(_ localizationBlock: @escaping (String?) -> String?)
  • Convert a view point to the normalized PDF coordinate space. bounds is from the view. (usually PSPDFPageView.bounds)

    Declaration

    Objective-C

    extern CGPoint PSPDFConvertViewPointToPDFPoint(CGPoint viewPoint,
                                                   PSPDFPageInfo *_Nonnull pageInfo,
                                                   CGRect viewBounds)

    Swift

    func PSPDFConvertViewPointToPDFPoint(_ viewPoint: CGPoint, _ pageInfo: PDFPageInfo, _ viewBounds: CGRect) -> CGPoint
  • Converts a point in a normalized PDF coordinate space to the view coordinate space.

    Declaration

    Objective-C

    extern CGPoint PSPDFConvertPDFPointToViewPoint(CGPoint pdfPoint,
                                                   PSPDFPageInfo *_Nonnull pageInfo,
                                                   CGRect viewBounds)

    Swift

    func PSPDFConvertPDFPointToViewPoint(_ pdfPoint: CGPoint, _ pageInfo: PDFPageInfo, _ viewBounds: CGRect) -> CGPoint
  • Converts a rectangle from a normalized PDF coordinate space to the view coordinate space.

    Note

    Important: This is not a general purpose conversion function from PDF page to UIKit coordinates! If the pdfRect has negative width or height, the results will be unexpected.

    Declaration

    Objective-C

    extern CGRect PSPDFConvertPDFRectToViewRect(CGRect pdfRect,
                                                PSPDFPageInfo *_Nonnull pageInfo,
                                                CGRect viewBounds)

    Swift

    func PSPDFConvertPDFRectToViewRect(_ pdfRect: CGRect, _ pageInfo: PDFPageInfo, _ viewBounds: CGRect) -> CGRect
  • Converts a rectangle in a view coordinate space to the normalized PDF coordinate space.

    Note

    Important: This is not a general purpose conversion function from UIKit to PDF page coordinates! If the viewRect has negative width or height, the results will be unexpected.

    Declaration

    Objective-C

    extern CGRect PSPDFConvertViewRectToPDFRect(CGRect viewRect,
                                                PSPDFPageInfo *_Nonnull pageInfo,
                                                CGRect viewBounds)

    Swift

    func PSPDFConvertViewRectToPDFRect(_ viewRect: CGRect, _ pageInfo: PDFPageInfo, _ viewBounds: CGRect) -> CGRect
  • Performs a block and groups all observed changes into one event, if the undo controller is available.

    Declaration

    Objective-C

    extern void
    PSPDFPerformBlockAsGroup(PSPDFUndoController *_Nullable undoController,
                             dispatch_block_t _Nonnull block,
                             NSString *_Nullable name)

    Swift

    class func performAsGroup(undoController: UndoController?, closure block: () -> Void, name: String?)
  • Performs a block and ignores all observed changes, if the undo controller is available.

    Declaration

    Objective-C

    extern void
    PSPDFPerformBlockWithoutUndo(PSPDFUndoController *_Nullable undoController,
                                 dispatch_block_t _Nonnull block)

    Swift

    class func performWithoutUndo(undoController: UndoController?, closure block: () -> Void)
  • Convert view lines to PDF lines.

    Declaration

    Swift

    public func ConvertToPDFLines(viewLines: [[CGPoint]], pageInfo: PDFPageInfo, viewBounds: CGRect) -> [[DrawingPoint]]
  • Converts a single line of boxed CGPoint.

    Declaration

    Swift

    public func ConvertToPDFLine(viewLine: [CGPoint], pageInfo: PDFPageInfo, viewBounds: CGRect) -> [DrawingPoint]